/**  
* @Title: WechatSiteUserOrder.java
* @Package com.hjb.service.controller.Wechat
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>panxinwen
* @date 2018年1月10日 下午11:41:20
* @version V1.0  
*/ 
package com.hjb.service.controller.Wechat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hjb.service.Wechat.WechatSiteUserOrderService;
import com.hjb.service.annotation.LogInfo;
import com.hjb.service.annotation.LogType;
import com.hjb.service.config.session.JXSession;
import com.hjb.service.config.session.SessionKey;
import com.hjb.service.config.session.SessionManager;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
* @ClassName: WechatSiteUserOrder
* @Description: TODO(公众号端合同管理)
* @author <a href="mailto:125671254@qq.com">Pan Xinwen</a>panxinwen
* @date 2018年1月10日 下午11:41:20
*
*/
@RestController
@RequestMapping("/Wechat/siteUserOrder")
@Api(value="/Wechat/siteUserOrder",description="公众号端合同管理"	)
public class WechatSiteUserOrderController {

	@Autowired
	private WechatSiteUserOrderService wechatSiteUserOrderService;
	
	@SuppressWarnings("rawtypes")
	@LogInfo(logType = LogType.查询, operationContent = "租户正在进行中的合同查询")
	@PostMapping("/getOrder")
	@ResponseBody
	@ApiOperation("租户合同查询")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "String", name = "phonenumber", value = "租户手机号", required = false)})
	public ResponseEntity getSiteUserOrder(@RequestParam(value = "phonenumber", required = true) String phonenumber){
		
		return ResponseEntity.ok(wechatSiteUserOrderService.getUserOrder(phonenumber, 0));
		
	}
	
	@SuppressWarnings("rawtypes")
	@LogInfo(logType = LogType.修改, operationContent = "租户合同确认")
	@PostMapping("/verifyOrder")
	@ResponseBody
	@ApiOperation("租户合同确认")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "String", name = "orderId", value = "合同编号", required = false)})
	public ResponseEntity verifySiteUserOrder(@RequestParam(value = "orderId", required = true) String orderId){
		
		return ResponseEntity.ok(wechatSiteUserOrderService.verifySiteUserOrder(orderId));
		
	}

	@SuppressWarnings("rawtypes")
	@LogInfo(logType = LogType.查询, operationContent = "获取电子合同填充数据")
	@PostMapping("/getEc")
	@ResponseBody
	@ApiOperation("租户合同查询")
	@ApiImplicitParams({ @ApiImplicitParam(paramType = "query", dataType = "String", name = "userId", value = "用户id", required = false),
		@ApiImplicitParam(paramType = "query", dataType = "String", name = "orderId", value = "合同编号", required = false)})
	public ResponseEntity getElectronicContract(@RequestParam(value = "userId", required = true) String userId,
			@RequestParam(value = "orderId", required = true) String orderId){
		
		return ResponseEntity.ok(wechatSiteUserOrderService.getElectronicContract(userId,orderId));
		
	}
	
}
